home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / xampp-win32-1.6.5-installer.exe / phpMyAdmin / libraries / parse_analyze.lib.php < prev    next >
Encoding:
PHP Script  |  2007-12-20  |  1.7 KB  |  57 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: parse_analyze.lib.php 10142 2007-03-20 10:32:13Z cybot_tm $
  6.  */
  7.  
  8. /**
  9.  *
  10.  */
  11. $GLOBALS['unparsed_sql'] = $sql_query;
  12. $parsed_sql = PMA_SQP_parse($sql_query);
  13. $analyzed_sql = PMA_SQP_analyze($parsed_sql);
  14.  
  15. // lem9: for bug 780516: now that we use case insensitive preg_match
  16. // or flags from the analyser, do not put back the reformatted query
  17. // into $sql_query, to make this kind of query work without
  18. // capitalizing keywords:
  19. //
  20. // CREATE TABLE SG_Persons (
  21. //  id int(10) unsigned NOT NULL auto_increment,
  22. //  first varchar(64) NOT NULL default '',
  23. //  PRIMARY KEY  (`id`)
  24. // )
  25.  
  26. // check for a real SELECT ... FROM
  27. $is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
  28.  
  29. // If the query is a Select, extract the db and table names and modify
  30. // $db and $table, to have correct page headers, links and left frame.
  31. // db and table name may be enclosed with backquotes, db is optionnal,
  32. // query may contain aliases.
  33.  
  34. /**
  35.  * @todo if there are more than one table name in the Select:
  36.  * - do not extract the first table name
  37.  * - do not show a table name in the page header
  38.  * - do not display the sub-pages links)
  39.  */
  40. if ($is_select) {
  41.     $prev_db = $db;
  42.     if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
  43.         $table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
  44.     }
  45.     if (isset($analyzed_sql[0]['table_ref'][0]['db'])
  46.       && strlen($analyzed_sql[0]['table_ref'][0]['db'])) {
  47.         $db    = $analyzed_sql[0]['table_ref'][0]['db'];
  48.     } else {
  49.         $db = $prev_db;
  50.     }
  51.     // Nijel: don't change reload, if we already decided to reload in import
  52.     if (empty($reload)) {
  53.         $reload  = ($db == $prev_db) ? 0 : 1;
  54.     }
  55. }
  56. ?>
  57.